/**
 * Testclass
 * @author Lukas Koell
 * @author David Medenjak
 * @author Johannes Riedmann
 */
public class Test {

    private static String hr = "---------------------------------------------------"
            + "---------------------------------------------";

    /**
     * @param args
     */
    public static void main(String[] args) {
        print("Welcome to the Test suite of Round 7!");
        print("Note, even though it's not explicitly said, some tests use \"Animal a = new Type()\" to test the method calls.");
        hr();
        print("First, we create a transporter with 3 couplings");
        Transporter t = new Transporter(3, null);
        print("Now, we create Giraffe Michaela and add it:");
        Animal g = new Giraffe("Michaela");
        try {
            t.load(g);
            print(t.list(""));
        } catch (Exception e) {
            e.printStackTrace();
        }
        hr();
        print("create a trailer and add Manni the elephant:");
        Trail anh = new Trail(3, null);
        Elefant manni = new Elefant("Manni");
        t.load(anh);
        anh.load(manni);
        print(t.list(""));
        hr();
        print("Creating a new Transporter and adding 3 Departments to the transporter: ");
        PythonTerrarium pt = new PythonTerrarium();
        WasserLandTank wlt = new WasserLandTank();
        RiesenschildkroetenTerrarium rst = new RiesenschildkroetenTerrarium();
        Compartment[] abteile = new Compartment[3];
        abteile[0] = pt;
        abteile[1] = wlt;
        abteile[2] = rst;

        Transporter t2 = new Transporter(1, abteile);
        print(t2.list(""));

        hr();
        print("Adding a Snakie the Mamba:");
        t2.load(new Mamba("Snakie"));
        print(t2.list(""));
        hr();
        print("Adding Doggy the Seehund:");
        t2.load(new Seehund("Doggy"));
        print(t2.list(""));
        hr();
        print("Adding Schildi the Zwergschildkr�te");
        Animal a = new Zwergschildkroete("Schildi");
        if (t2.load(a)) {
            print("Schildi added. Good.");
        } else {
            print("Adding schildi failed. Bad.");
        }
        print(t2.list(""));
        hr();
        print("Trying to add Kaa the Python (should go wrong)");
        if (t2.load(new Python("Kaa"))) {
            print("Adding Kaa did work - Test FAILed");
        } else {
            print("Could not add Kaa - This is good!");
        }
        print("The Transporter looks like this (should not have changed)");
        print(t2.list(""));
        hr();
        print("We add giraffe Michaela again");
        t2.load(g);
        print(t2.list(""));
        hr();
        print("We first unload all animals in departments");
        t2.unload(wlt);
        t2.unload(rst);
        t2.unload(pt);
        print(t2.list(""));
        hr();
        print("Then we unload Michaela from the hitch (she should still be here)");
        t2.unload(0);
        print(t2.list(""));
        hr();
        print("Trying to put a Seehund into a Python-Terrarium");
        pt.insertSeehund(new Seehund("Doggy"));
        if (pt.getAnimal() == null) {
            print("Couldn't put Seehund Doggy into Python-Terrarium");
        } else {
            print("In Python-Terrarium: " + pt.getAnimal().getName());
        }
        print("Trying to put a Mamba into a Wassertank");
        Wassertank wt = new Wassertank();
        wt.insertMamba(new Mamba("Mambino"));
        if (wt.getAnimal() == null) {
            print("Couldn't put Mamba Mambino into Wassertank");
        } else {
            print("In Wassertank: " + wt.getAnimal().getName());
        }
        print("Trying to put Zwergschildkroete Zwergschildi into RiesenschildkroetenTerrarium");
        RiesenschildkroetenTerrarium rst1 = new RiesenschildkroetenTerrarium();
        rst1.insertZwergschildkroete(new Zwergschildkroete("Zwergschildi"));
        if (rst1.getAnimal() == null) {
            print("Couldn't put Zwergschildkroete Zwergschildi into RiesenschildkroetenTerrarium");
        } else {
            print("In RiesenschildkroetenTerrarium: " + rst1.getAnimal().getName());
        }
    }

    private static void hr() {
        print(hr);
    }

    private static void print(String msg) {
        System.out.println(msg);
    }
}
